package thread;

public class Demo3 {
    public static void main(String[] args) {
        //创建一个匿名内部类
        Thread thread = new Thread(){
            public void run(){
                while(true){
                    System.out.println("Hello mythread!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };

        //启动这个线程
        thread.start();
        while(true){
            System.out.println("Hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
